<!DOCTYPE html>
<!--[if IE 8]> <html lang="en" class="ie8 no-js"> <![endif]-->
<!--[if IE 9]> <html lang="en" class="ie9 no-js"> <![endif]-->
<!--[if !IE]><!-->
<html xmlns:th="http://www.thymeleaf.org">
<!--<![endif]-->
<!-- BEGIN HEAD -->

<head>
    <meta charset="utf-8" />
    <title>订单管理-优惠券管理</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta content="width=device-width, initial-scale=1" name="viewport" />
    <!-- Bootstrap 3.3.6 -->
    <link rel="stylesheet" href="../superui/content/ui/global/bootstrap/css/bootstrap.min.css"
          th:href="@{/superui/content/ui/global/bootstrap/css/bootstrap.min.css}"/>
    <!-- Font Awesome -->
    <link rel="stylesheet" href="../superui/content/ui/global/font-awesome/css/font-awesome.css"
          th:href="@{/superui/content/ui/global/font-awesome/css/font-awesome.css}"/>
    <!-- Theme style -->
    <link rel="stylesheet" href="../superui/content/adminlte/dist/css/AdminLTE.css"
          th:href="@{/superui/content/adminlte/dist/css/AdminLTE.css}"/>
    <link rel="stylesheet" href="../superui/content/adminlte/dist/css/skins/_all-skins.min.css"
          th:href="@{/superui/content/adminlte/dist/css/skins/_all-skins.min.css}"/>
    <link rel="stylesheet" href="../superui/content/min/css/supershopui.common.min.css"
          th:href="@{/superui/content/min/css/supershopui.common.min.css}"/>
    <link rel="stylesheet" href="../superui/content/plugins/bootstrap-table/bootstrap-table.css"
          th:href="@{/superui/content/plugins/bootstrap-table/bootstrap-table.css}"/>
    <link rel="stylesheet" href="../css/global.css"
          th:href="@{/css/global.css}"/>
    <!--全局通用框架样式 end-->

    <!-- iCheck -->
    <link rel="stylesheet" href="../superui/content/plugins/iCheck/square/blue.css"
          th:href="@{/superui/content/plugins/iCheck/square/blue.css}"/>

</head>
<body>
<section class="content-header">
    <h1>
        优惠券管理
    </h1>
    <ol class="breadcrumb">
        <li><a href="#"><i class="fa fa-dashboard"></i> Home</a></li>
        <li><a href="#">订单管理</a></li>
        <li class="active">优惠券管理</li>
    </ol>
</section>
<!-- Main content -->
<section class="content">

    <div class="row">
        <!-- BEGIN SAMPLE TABLE PORTLET-->
        <div class="col-md-12">
            <!-- BEGIN SAMPLE TABLE PORTLET-->
            <div class="box-body">
                <div class="panel panel-default no-margin">
                    <div class="panel-body search-box">
                        <form id="formSearch" class="form-horizontal">
                            <div class="col-md-3">
                                <div class="form-group">
                                    <label for="txt_search_couponName" class="col-sm-4 control-label">优惠券名称</label>
                                    <div class="col-sm-8">
                                        <input id="txt_search_couponName" name="couponName" class="form-control" type="text" value="" placeholder="请输入优惠券卡号">
                                    </div>
                                </div>
                            </div>
                            <div class="col-md-3">
                                <div class="form-group">
                                    <label class="col-sm-3 control-label"></label>
                                    <div class="col-sm-9">
                                        <button type="button" class="btn btn-default" id="btn-search" onclick="clickSearch()">
                                            <i class="fa  fa-search"></i>
                                            查询
                                        </button>
                                    </div>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>

                <div id="couponCardTableToolbar" class="btn-group">
                    <button id="btn_add" type="button" class="btn btn-primary" onclick="clickAddBtn()">
                        <span class="glyphicon glyphicon-plus" aria-hidden="true"></span>新增
                    </button>
                </div>
                <div class="table-scrollable">
                    <table class="table-striped table-hover" id="couponCardTable">

                    </table>
                </div>
            </div>
            <!-- END SAMPLE TABLE PORTLET-->


            <div id="couponCardDialog" class="hide">
                <form id="frmMain" class="form-horizontal">
                    <div class="box-body" style="width: 99%">
                        <input type="hidden" id="id" name="id" value="">
                        <div class="form-group">
                            <label for="couponName" class="col-sm-3 control-label necessary">优惠券名称</label>
                            <div class="col-sm-7">
                                <input type="text" class="form-control" id="couponName" name="couponName" placeholder="请输入优惠券名称" />
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="useTypeId" class="col-sm-3 control-label necessary">可用分类</label>
                            <div class="col-sm-7">
                                <select class="form-control" id="useTypeId" name="useTypeId">
                                    <option value="0"> 选择全部</option>
                                    <option value="1"> 课外辅导</option>
                                    <option value="2"> 研学旅行</option>
                                    <option value="3"> 冬夏令营</option>
                                    <option value="4"> 在线课程</option>
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="useCondition" class="col-sm-3 control-label necessary">触发条件</label>
                            <div class="col-sm-7">
                                <select class="form-control" id="useCondition" name="useCondition">
                                    <option value="1"> 注册优惠券</option>
                                    <option value="2"> 完善资料优惠券</option>
                                    <option value="3"> 主动领取</option>
                                    <option value="4"> 新用户专享优惠券</option>
                                    <option value="5"> 老用户专享优惠券</option>
                                </select>
                            </div>
                        </div>
                        <!-- <div class="form-group" id="chooseUserBtn" hidden>
                             <label class="col-sm-3 control-label necessary">请选择用户</label>
                             <div class="col-sm-7">
                                 <select class="form-control" id="chooseUser" title="用户类型">
                                     <option value="newUser"> 新用户</option>
                                     <option value="oldUser"> 老用户</option>
                                 </select>
                             </div>
                         </div>-->
                        <div class="form-group" hidden id="form_group_coupon_sum">
                            <label for="conditionalAmount" class="col-sm-3 control-label necessary">数量</label>
                            <div class="col-sm-7">
                                <div class="input-group">
                                    <input type="number" class="form-control" id="couponSum" name="couponSum"
                                           placeholder="请输入生成优惠券数量"/>
                                    <div class="input-group-addon">张</div>
                                </div>
                            </div>
                        </div>

                        <div class="form-group" hidden>
                            <label for="conditionalAmount" class="col-sm-3 control-label necessary">可领券用户ID</label>
                            <div class="col-sm-7">
                                <div class="input-group">
                                    <input type="text" class="form-control" id="receiveUserIds" name="receiveUserIds"/>
                                </div>
                            </div>
                        </div>

                        <div class="form-group">
                            <label for="conditionalAmount" class="col-sm-3 control-label necessary">使用条件</label>
                            <div class="col-sm-7">
                                <div class="input-group">
                                    <input type="number" class="form-control" id="conditionalAmount" name="conditionalAmount"
                                           placeholder="请输入使用条件"/>
                                    <div class="input-group-addon">元</div>
                                </div>
                            </div>
                        </div>

                        <div class="form-group">
                            <label for="usefulTime" class="col-sm-3 control-label necessary">有效期限</label>
                            <div class="col-sm-7">
                                <div class="input-group">
                                    <input type="number" step="1" class="form-control" id="usefulTime" name="usefulTime" value="1"
                                           placeholder="请输入优惠券有效期限"/>
                                    <div class="input-group-addon">天</div>
                                </div>
                            </div>
                        </div>

                        <div class="form-group">
                            <label for="discountAmount" class="col-sm-3 control-label necessary">优惠金额</label>
                            <div class="col-sm-7">
                                <div class="input-group">
                                    <input type="number" step="0.01" class="form-control" id="discountAmount" name="discountAmount" placeholder="请输入优惠金额" />
                                    <span class="input-group-addon">元</span>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="box box-primary" hidden id="form_group_receive_user_ids">
                        <div class="box-header with-border">
                            <h3 class="box-title">可领券用户</h3>
                            <span style="margin-left: 3%; color: #ff4624;">(取消领取或添加学员后请点击保存按钮保存信息)</span>
                            <!--批量绑定按钮-->
                            <div class="btn-group pull-right" style="margin-right: 30px" id="batchBtn">
                                <button id="btn_batch" type="button" class="btn btn-primary" onclick="clickBatchBtn()">
                                    <span class="fa fa-share-square-o" aria-hidden="true"></span>批量添加学员
                                </button>
                            </div>

                            <div class="box-tools pull-right">
                                <button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i></button>
                            </div>
                        </div>
                        <div class="box-body" style="max-height: 300px;overflow-y: auto;">
                            <table id="dt-inspection-content" class="table table-bordered table-striped table-hover">
                                <thead>
                                <tr>
                                    <th>序号</th>
                                    <th>学员ID</th>
                                    <th>学员名</th>
                                    <th>学员手机号</th>
                                    <th>操作</th>
                                </tr>
                                </thead>
                                <tbody id="userTableBody">

                                </tbody>
                            </table>
                        </div>
                    </div>
                </form>
            </div><!-- /.modal -->

            <!--批量绑定弹出框-->
            <div id="receiveUserBatchDialog" class="hide">
                <div class="box-body">
                    <div class="panel panel-default no-margin">
                        <div class="panel-body search-box">
                            <form id="formSearch1" class="form-horizontal">
                                <div class="col-md-3">
                                    <div class="form-group">
                                        <label for="txt_search_name" class="col-sm-4 control-label">学员名</label>
                                        <div class="col-sm-8">
                                            <input id="txt_search_name" name="name" class="form-control" type="text" value=""
                                                   placeholder="请输入学员名">
                                        </div>
                                    </div>
                                </div>
                                <div class="col-md-3">
                                    <div class="form-group">
                                        <label for="txt_search_phone" class="col-sm-4 control-label">学员手机</label>
                                        <div class="col-sm-8">
                                            <input id="txt_search_phone" name="phone" class="form-control" type="text" value=""
                                                   placeholder="请输入学员手机号">
                                        </div>
                                    </div>
                                </div>

                                <div class="form-group fl" style="width: 350px; margin-right: 10px">
                                    <label class="col-sm-4 control-label"></label>
                                    <div class="col-sm-8">
                                        <button type="button" class="btn btn-default" id="btn_search"
                                                onclick="ReceiveUserBatchInfoDlg.clickSearchUser()">
                                            <i class="fa  fa-search"></i>
                                            查询
                                        </button> &nbsp;&nbsp;&nbsp;
                                    </div>
                                </div>
                            </form>
                        </div>
                    </div>

                    <div class="table-scrollable">
                        <table class="table-striped table-hover" id="userTable">

                        </table>
                    </div>
                </div>
            </div>

            <div id="couponCardItemsDialog">
                <div style="padding: 10px;">
                    <div id="couponCardItemsTableToolbar" class="btn-group">

                    </div>
                    <table class="table-striped table-hover" id="couponCardItemsTable">

                    </table>
                </div>

            </div>
        </div>
    </div>

</section>
<!-- REQUIRED JS SCRIPTS -->
<!-- jQuery 2.2.3 -->
<script src="../superui/content/ui/global/jQuery/jquery.min.js"
        th:src="@{/superui/content/ui/global/jQuery/jquery.min.js}"></script>
<!-- Bootstrap 3.3.6 -->

<script src="../superui/content/ui/global/bootstrap/js/bootstrap.min.js"
        th:src="@{/superui/content/ui/global/bootstrap/js/bootstrap.min.js}"></script>
<!--supershopui-->
<script src="../superui/content/min/js/supershopui.common.js"
        th:src="@{/superui/content/min/js/supershopui.common.js}"></script>

<!--bootstrap-table-->
<script src="../superui/content/plugins/bootstrap-table/bootstrap-table.js"
        th:src="@{/superui/content/plugins/bootstrap-table/bootstrap-table.js}"></script>
<script src="../superui/content/plugins/bootstrap-table/locale/bootstrap-table-zh-CN.js"
        th:src="@{/superui/content/plugins/bootstrap-table/locale/bootstrap-table-zh-CN.js}"></script>
<script src="../js/assets/common/bootstrap-table-object.js"
        th:src="@{/js/assets/common/bootstrap-table-object.js}"></script>
<!-- iCheck -->
<script src="../superui/content/plugins/iCheck/icheck.min.js"
        th:src="@{/superui/content/plugins/iCheck/icheck.min.js}"></script>

<script src="./../../js/assets/common/Feng.js"
        th:src="@{/js/assets/common/Feng.js}"></script>
<!-- 请求脚本-->
<script src="./../../js/assets/common/ajax-util.js"
        th:src="@{/js/assets/common/ajax-util.js}"></script>
<!-- 请求脚本-->
<script src="./../../js/assets/common/common.js"
        th:src="@{/js/assets/common/common.js}"></script>
<script src="../../js/assets/lib/numeral/numeral.min.js"
        th:src="@{/js/assets/lib/numeral/numeral.min.js}"></script>

<script th:inline="javascript">
    /*<![CDATA[*/
    var baseUrl = [[${#httpServletRequest.getContextPath()}]];
    //    var baseUrl = [[@{/}]];
    if (baseUrl === '/') baseUrl = '';
    Feng.addCtx(baseUrl);
    /*]]>*/
</script>
<!-- 模板引擎-->
<script src="../../js/assets/lib/artTemplate/template.js"
        th:src="@{/js/assets/lib/artTemplate/template.js}"></script>
<!-- 优惠券脚本-->
<script src="./../../js/order/couponcard/couponcard.js"
        th:src="@{/js/order/couponcard/couponcard.js}"></script>
<script src="./../../js/order/couponcard/couponcard_info.js"
        th:src="@{/js/order/couponcard/couponcard_info.js}"></script>
<script src="./../../js/order/couponcard/couponcardItems.js"
        th:src="@{/js/order/couponcard/couponcardItems.js}"></script>
<script src="./../../js/order/couponcard/couponcard_user_batch.js"
        th:src="@{/js/order/couponcard/couponcard_user_batch.js}"></script>

<!-- 领券用户表格模板 -->
<script type="text/html" id="dataReceiveUserContentTmpl">
    {{each}}
    <tr>
        <td>{{$index+1}}</td>
        <td>{{$value.userId}}</td>
        <td>{{$value.userName||"无"}}</td>
        <td>{{$value.userPhone||"无"}}</td>
        <td data-id="{{$value.couponItemId || $index}}">
            {{if $value.isNewUser === "YES"}}
            <a title="删除" href="#"
               onclick="CouponCardInfoDlg.deleteReceiveUser('{{$value.couponItemId}}','{{$value.userId}}','{{$value.isNewUser}}')"
               data-target="delete">删除</a>
            {{/if}}
            {{if $value.couponState !== "4"}}
            <span>已领取</span>
            {{/if}}
        </td>
    </tr>
    {{/each}}
</script>
</body>
</html>